import { ActiveBaseIcon } from "../activity/icon/ActiveBaseIcon";
import { ResFileConst } from "../../resource/ResFileConst";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SecTimer } from "../../../../com/gengine/core/frame/SecTimer";
import { TimerType } from "../../../../com/gengine/core/frame/TimerType";
import { RemainTimeTool } from "../award/RemainTimeTool";
import { HighlightManager } from "../../manager/HighlightManager";
import { GLabel } from "../../../../com/mui/controls/GLabel";
type int = number;
//class ZodiacIconBtn
    
    export  class ZodiacIconBtn extends ActiveBaseIcon
    {
        constructor(arg1: string=null)
        {
            super(ResFileConst.ZodiacMainBtn);
            this.initBtn();
            return;
        }

        /* internal  */initBtn(): void
        {
            this._timeLabel = ObjCreate.createLabel("", 4, 50, 52, 20, flash.text.TextFormatAlign.CENTER, this, true, GlobalStyle.greenUint);
            return;
        }

        protected /* override */ onMouseClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.ClickZodiacIcon));
            return;
        }

        public setTime(arg1: int): void
        {
            this._time = arg1;
            this.startTimerCount();
            return;
        }

        /* internal  */startTimerCount(): void
        {
            if (!this._timer) 
            {
                this._timer = new SecTimer();
                this._timer.addListener(TimerType.ENTERFRAME, this.onTimerHandler);
                this._timer.start();
            }
            return;
        }

        /* internal  */onTimerHandler(arg1: SecTimer): void
        {
            --this._time;
            this._timeLabel.htmlText = RemainTimeTool.getRemainTimeBySeconds(this._time);
            return;
        }

        public addHighLightEffect(): void
        {
            HighlightManager.instance.glowEffectButton(this, true);
            return;
        }

        public removeHighLightEffect(): void
        {
            HighlightManager.instance.glowEffectButton(this, false);
            return;
        }

        /* internal */ /* var */_time: int;

        /* internal */ /* var */_timer: SecTimer;

        /* internal */ /* var */_timeLabel: GLabel;
    }
